<!--待办-->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <i class="iconfont iconshuxian"></i>待办事宜
                    <div class="rightFunction">
                        <a href="/index#/workflow/task/view/pendingMatters" target="_blank">
                            <i class="iconfont iconangle-right "></i>
                        </a>
                    </div>
                </div>
                <div class="layui-card-body" style="padding:0">
                    <ul class="todoEvents" style="margin:20px 0 0 0" id="pendingContent">

                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<!--已办-->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <i class="iconfont iconshuxian"></i>已办事宜
                    <div class="rightFunction">
                        <a href="/index#/workflow/processRun/view/alreadyMatter" target="_blank">
                            <i class="iconfont iconangle-right "></i>
                        </a>
                    </div>
                </div>
                <div class="layui-card-body" style="padding:0">
                    <ul class="todoEvents" style="margin:20px 0 0 0 " id="alreadyContent">

                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 待办事宜 -->
<script>
    layui.use(['jquery'], function () {
        $.ajax({
            type: 'get',
            url: '/workflow/task/list/pendingMatters',
            dataType: 'json',
            async: false,
            success: function (data) {
                if(data != null && data.data != null && data.data.length > 0) {
                    let num = data.data.length < 5?data.data.length:5;
                    $('#pendingContent').html('');
                    for (var i = 0; i < num; i++) {

                        var content =
                              '<li>'
                            +   '<a href='+serverPath.workflowPath + setter.workflowLinkPath +"/task/view/toStart?taskId=' + data.data[i].id + '&instanceId='+ data.data[i].processInstanceId + '" target="_blank">'
                            +       '<p>'
                            +           '<span class="tit">'+ data.data[i].subject + '</span>'
                            +           '<i class="verticalLine"></i>'
                            +           '<cite>' + dateChange(data.data[i].createTime) + '</cite>'
                            +       '</p>'
                            +       '<div class="rightInfor">'
                            +           '<i class="iconfont iconicon_people_fill"></i>'
                            +           '<span>' + data.data[i].creator +'</span>'
                            +       '</div>'
                            +   '</a>'
                            + '</li>';

                        $('#pendingContent').append(content);
                    }
                }

            }, error: function (data) {
            }
        });
    });

    function dateChange(date) {
        if (date.toString().indexOf("-") == -1) {
            var date = new Date(date);
            Y = date.getFullYear() + '-';
            M = ((date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)) + '-';
            D = ((date.getDate() < 10) ? '0' + (date.getDate()) : date.getDate()) + ' ';
            h = ((date.getHours() < 10) ? '0' + (date.getHours()) : date.getHours()) + ':';
            m = ((date.getMinutes() < 10) ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
            s = ((date.getSeconds() < 10) ? '0' + (date.getSeconds()) : date.getSeconds()) + '';
            return Y + M + D + h + m +s;
        }else {
            return date;
        }
    }
</script>

<!--已办事宜-->
<script>
    layui.use(['jquery','setter'], function () {
        var setter = layui.setter;

        $.ajax({
            type: 'get',
            url: '/workflow/processRun/list/alreadyMatter',
            dataType: 'json',
            async: false,
            success: function (data) {
                if(data != null && data.data != null && data.data.length > 0){
                    let num = data.data.length < 5?data.data.length:5;
                    $('#alreadyContent').html('');
                    for (var i = 0; i < num; i++) {
                        var content =
                            '<li>'
                            +   '<a href="' + serverPath.workflowPath + setter.workflowLinkPath  + 'processRun/view/info?runId=' + data.data[i].runId + '&prePage=myFinishedTask" target="_blank">'
                            +       '<p>'
                            +           '<span class="tit">'+ data.data[i].subject + '</span>'
                            +           '<i class="verticalLine"></i>'
                            +           '<cite>' + dateChange2(data.data[i].createTime) + '</cite>'
                            +       '</p>'
                            +       '<div class="rightInfor">'
                            +           '<i class="iconfont iconicon_people_fill"></i>'
                            +           '<span>' + data.data[i].creator + '</span>'
                            +       '</div>'
                            +   '</a>'
                            + '</li>';

                        $('#alreadyContent').append(content);
                    }
                }

            }, error: function (data) {
            }
        });
    });

    function dateChange2(date) {
        if (date.toString().indexOf("-") == -1) {
            var date = new Date(date);
            Y = date.getFullYear() + '-';
            M = ((date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)) + '-';
            D = ((date.getDate() < 10) ? '0' + (date.getDate()) : date.getDate()) + ' ';
            h = ((date.getHours() < 10) ? '0' + (date.getHours()) : date.getHours()) + ':';
            m = ((date.getMinutes() < 10) ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
            s = ((date.getSeconds() < 10) ? '0' + (date.getSeconds()) : date.getSeconds()) + '';
            return Y + M + D + h + m +s;
        }else {
            return date;
        }
    }
</script>




